package com.buguniao.jobs;

import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by buguniao on 2017/7/23.
 */
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class PrintJob implements Job{
    Logger logger= LoggerFactory.getLogger(PrintJob.class);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDataMap dataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        int count = dataMap.getInt("count");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("job executing ...,count="+count+",jobdetails="+dataMap+",key="+jobExecutionContext.getJobDetail().getKey());
        dataMap.put("count",++count);
    }
}
